var selectedElement = undefined;

function searchComitesEtica(element, url){
    selectedElement = element;
    var name = selectedElement.val();
    var s = element.parent().parent().prev().children().get(1).children[0];
    var category = s.options[s.selectedIndex].value;
    windowCaller("Select Committee", url, { "comiteEticaName": name, "comiteCategoria": category });
}

function closeWindowsComitesEtica(id,nombre){
    $.window.closeAll();

    /*este elemento mostrara el nombre del comite seleccionado*/
    selectedElement.val(nombre);

    /*este elemento llevara al servidor el id del comite seleccionado*/
    selectedElement.prev().val(id);
}

function deleteRowCE(element) {

    if($('.comiteEticaClass').length>1){
        element.remove();
    }else{
        element.children(1).children(1).children(0).val('');
        element.children(1).children(1).children(1).val('');
    }

}

function addRowCommiteeC(element) {

    var counts = ++contadorParaNuevasFilas;

    var rowContact = element.clone()[0];

    rowContact.children[1].children[1].children[0].value = '';
    rowContact.children[1].children[1].children[0].name = 'comitesC['+counts+'].id';
    rowContact.children[1].children[1].children[1].value = '';
    element.after(rowContact);
}
